package com.lmf.controller;

import com.lmf.exception.AgeException;
import com.lmf.exception.MyUserException;
import com.lmf.exception.NameException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


@Controller
public class Mycontroller {

    @RequestMapping(value = "/some.do")
    public ModelAndView doSome(String name,Integer age) throws MyUserException {
        System.out.println("学生姓名："+name+"，学生年龄："+age);
        ModelAndView mv=new ModelAndView();
        //根据请求抛出异常
        if ( ! "zs".equals(name)) {
            throw new NameException("用户名异常");
        }
        if ( age == null || age > 80) {
            throw new AgeException("用户年龄异常");
        }
        mv.addObject("name",name);
        mv.addObject("age",age);
        mv.setViewName("show");
        return mv;
    }



}
